package com.zzl.boot.bigevent.service.impl;

import com.zzl.boot.bigevent.mapper.tagMapper;
import com.zzl.boot.bigevent.mapper.warehouseMapper;
import com.zzl.boot.bigevent.pojo.article;
import com.zzl.boot.bigevent.pojo.articleWarehouse;
import com.zzl.boot.bigevent.pojo.tag;
import com.zzl.boot.bigevent.pojo.warehouse;
import com.zzl.boot.bigevent.service.tagService;
import com.zzl.boot.bigevent.service.warehouseService;
import com.zzl.boot.bigevent.utils.ThreadLocalUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@Slf4j
public class implwarehouseService implements warehouseService {
    @Autowired
    private warehouseMapper Mapper;
    private Map<String,Object> map;

    @Override
    public void add(String warehouseName) {
        map=ThreadLocalUtil.get();
        Integer userId = (Integer) map.get("id");
        log.info("userId:{}",warehouseName+":"+userId);
        Mapper.add(warehouseName, userId);
    }

    @Override
    public List<warehouse> getList() {
        map=ThreadLocalUtil.get();
        return Mapper.getList((Integer)map.get("id"));
    }

    @Override
    public void update(warehouse warehouse) {
        Mapper.update(warehouse);
    }

    @Override
    public void del(Integer id) {
        Mapper.del(id);
    }

    @Override
    public void save(articleWarehouse articleWarehouse) {
        Mapper.save(articleWarehouse);
    }

    @Override
    public List<article> listByWare(Integer warehouseId) {
        return Mapper.listByWare(warehouseId);
    }

    @Override
    public Integer getcount(Integer warehouseId) {
        return Mapper.count(warehouseId);
    }

    @Override
    public void remove(Integer wid, Integer aid) {
        Mapper.remove(wid,aid);
    }

    @Override
    public int isExit(articleWarehouse articleWarehouse) {
        return Mapper.isExit(articleWarehouse);
    }

    @Override
    public void fristWarehouse(String username) {
        Mapper.fristWarehouse(username,"默认仓库");
    }
}
